//
//  WLGP_LabelCollectionViewCell.m
//  录音转文字助手
//
//  Created by 王亮 on 2020/9/9.
//  Copyright © 2020 录音转文字助手. All rights reserved.
//

#import "WLGP_LabelCollectionViewCell.h"
#import "WLAppleStore.h"

@interface WLGP_LabelCollectionViewCell ()
@property(nonatomic,strong) UILabel *label;
@property(nonatomic,strong) UIImageView *icon_image_view;

@end
@implementation WLGP_LabelCollectionViewCell

-(void)bind_row_data:(WLBaseCollectionViewLayerRow *)sender{
    NSString *string = sender.data;
    NSDictionary *otherData = sender.otherData;
    
    self.label.text = string;

    if (otherData){
        if ([otherData objectForKey:@"font"]){
            self.label.font = [otherData objectForKey:@"font"];
        }
        if ([otherData objectForKey:@"textColor"]){
            self.label.textColor = [otherData objectForKey:@"textColor"];
        }
        if ([otherData objectForKey:@"icon"]){
            self.icon_image_view.image = [otherData objectForKey:@"icon"];
            
         
            [self.icon_image_view mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self);
                make.centerX.mas_equalTo(self).mas_offset( - self.frame.size.width * 0.2f);
            }];
            [self.label mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self);
                make.left.mas_equalTo(self.icon_image_view.mas_right).mas_offset(5);
            }];
            
        }
    }
}
-(void)bind_delegate:(id)sender{
    
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColor.redColor;
        [self addSubview:self.label];
        [self addSubview:self.icon_image_view];
        [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsMake(0, 20, 0, 20));
        }];
        [self.icon_image_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.mas_equalTo(self);
        }];
    }
    return self;
}




-(UILabel *)label{
    if (!_label){
        _label = [[UILabel alloc]init];
        _label.numberOfLines = 0;
        _label.adjustsFontSizeToFitWidth = YES;
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor = UIColor.whiteColor;
        _label.font = [UIFont systemFontOfSize:9];
    }
    return _label;
}
-(UIImageView *)icon_image_view{
    if (!_icon_image_view){
        _icon_image_view = [[UIImageView alloc]init];
        _icon_image_view.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _icon_image_view;
}
@end

@implementation WLGP_LabelCollectionViewCellModel



@end
